//
//  KLMeCell.m
//  Meboo
//
//  Created by kyo on 2024/1/5.
//

#import "KLMeCell.h"

@interface KLMeCell()
@property(nonatomic,strong) UILabel *titleLab;
@property(nonatomic,strong) UIView *lineView;
@end

@implementation KLMeCell
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - Public Metohd
- (void)setTitleStr:(NSString *)titleStr {
    _titleStr = titleStr;
    self.titleLab.text = titleStr;
    if ([titleStr isEqualToString:@"Help center"] || [titleStr isEqualToString:@"Delete account"]) {
        self.lineView.hidden = YES;
    } else {
        self.lineView.hidden = NO;
    }
}

#pragma mark - UI
- (void)setupUI {
    self.contentView.backgroundColor = UIColor.clearColor;
    
    [self.contentView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.mas_equalTo(MBWidthScale(25));
        make.height.width.mas_equalTo(MBHeightScale(28));
    }];
    
    [self.contentView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.iconImageView.mas_right).offset(MBWidthScale(22));
    }];
    
    [self.contentView addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView);
        make.right.mas_equalTo(MBWidthScale(-22));
        make.left.mas_equalTo(MBWidthScale(22));
        make.height.mas_equalTo(1);
    }];
}

#pragma mark - Setter && Getter
- (UIImageView *)iconImageView {
    if (!_iconImageView) {
        _iconImageView = [UIImageView new];
        _iconImageView.image = ImageWithName(@"flower_defult");
    }
    return _iconImageView;
}


- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.font = MBHelBoldFontSizeScale(15);
        _titleLab.textColor = HEXS(@"000000");
    }
    return _titleLab;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = HEXS(@"E2DCFF");
    }
    return _lineView;
}
@end
